<template>
	<!-- 名称/简介 -->
	<u-popup :show="show" bgColor="#F7F7F7" :round="20" mode="bottom" closeable @close="cancel" @open="open">
		<view class="title">{{title}}</view>
		<view class="main-box">
			<view class="input-box" v-if="type==1">
				<u--input v-model="inputvalue" placeholder="请输入内容" border="none" clearable
					shape="circle"></u--input>
			</view>
			<view class="texts-box" v-if="type==2">
				<u--textarea v-model="inputvalue" placeholder="请输入内容" border="none" > </u--textarea>
			</view>
			
			<view class="btn" @click="submit" :style="{'backgroundColor':bgColor}">确定</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
		props: {
			// 输入的值
			value: {
				type: [String, Number],
				default: ''
			},
			show: {
				type: Boolean,
				default: false
			},
			title: {
				type: String,
				default: ''
			},
			bgColor: {
				type: String,
				default: '#4660FE'
			},
			// 1 input 2 文本域
			type: {
				type: Number,
				default: 1
			}
		},
		data() {
			return {
				inputvalue: ''
			};
		},
		mounted() {

		},

		methods: {
			cancel() {
				this.$emit('update:show', false)
			},
			open() {
				this.inputvalue = this.value
			},
			submit() {
				if (this.inputvalue == "") {
					return uni.$u.toast("请输入内容")
				}
				this.$emit('update:show', false);
				this.$emit('submit', this.inputvalue)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.title {
		width: 100%;
		height: 100rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 36rpx 36rpx 0 0;
		background: #ffffff;
	}

	.main-box {
		width: 100%;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		gap: 60rpx;
		padding: 30rpx 40rpx;
		.input-box{
			height: 100rpx;
			border-radius: 16rpx;
			display: flex;
			align-items: center;
			padding: 0 20rpx;
			background: #ffffff;
		}
		.texts-box{
			
		}

		.btn {
			width: 100%;
			height: 90rpx;
			border-radius: 106rpx;
			opacity: 1;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 30rpx;
			background: linear-gradient( 90deg, #F6D9AF 0%, #C49A4F 100%);
			color: #fff;
		}
	}
</style>